home *** CD-ROM | disk | FTP | other *** search
/ 17 Bit Software 6: Level 6 / 17 Bit - Level 6 (1998)(Epic Marketing)[!].iso / !applications! / symphonie / dsplugin / dspplugin delay.s < prev    next >
Text File  |  1994-04-11  |  5KB  |  336 lines

  1.  
  2. ; Simple DSP Delay algorithm V1.0 - For Demonstration
  3.  
  4. ; A Ringbuffer is installed using SST_GetMem
  5. ; Fixed Size of Delay in SampleNumb 
  6. ;  -> Fixed Length (time) at same MixFreq
  7. ; Actual Delay PTRs are displayed (if FORCE UPATE IS ON)
  8. ; If no buffer mem has been allocated, the delay algorithm
  9. ; won't be processed (using RingBufMem_STATUS)
  10.  
  11.     ;- BEGIN -------------------------------------------------
  12.  
  13.     MC68020
  14.  
  15. SST_SYS_GetMem            EQU    0
  16. SST_SYS_FreeMem            EQU    4
  17.  
  18. SST_FILE_RequestFileName    EQU    100
  19. SST_FILE_SetReqPattern        EQU    104
  20. SST_FILE_SetReqDir        EQU    108
  21. SST_FILE_GetFileName        EQU    112
  22. SST_FILE_GetFileLen        EQU    116
  23.  
  24. SST_GFX_AssistText        EQU    200
  25. SST_GFX_AssistDecLong        EQU    204
  26. SST_GFX_AssistDecByte        EQU    208
  27. SST_GFX_AssistHexLong        EQU    212
  28.  
  29. SST_AUDIO_GetChunkLen        EQU    400
  30.  
  31. SST_PTR_EXECBASE        EQU    1600
  32. SST_PTR_INTBASE            EQU    1604
  33. SST_PTR_DOSBASE            EQU    1608
  34. SST_PTR_ASLBASE            EQU    1612
  35. SST_PTR_REQTOOLSBASE        EQU    1616
  36. SST_PTR_GFXBASE            EQU    1620
  37.  
  38. SST_PTR_Screen            EQU    1650
  39.  
  40. SST_ADR_ProcessorFlags        EQU    1800
  41. SST_ADR_SystemFrequency        EQU    1804
  42. SST_ADR_SystemBpm        EQU    1808
  43. SST_ADR_ChunkLen        EQU    1812
  44. SST_ADR_OversampleFlag        EQU    1816
  45.  
  46.  
  47. FASTMEM    EQU    $10004
  48. ANYMEM    EQU    $10000
  49.  
  50. CALLSST    macro
  51.     move.l    #SST_\1,d7
  52.     bsr    GoSST
  53.     endm
  54.  
  55. FLASH    macro
  56.     move.w    #$\1,$dff180
  57.     endm
  58.  
  59. BGN    macro
  60.     movem.l    d0-d7/a0-a6,-(a7)
  61.     endm
  62.  
  63. RET    macro
  64.     movem.l    (a7)+,d0-d7/a0-a6
  65.     rts
  66.     endm
  67.  
  68. puts    macro
  69.     movem.l    \1,-(sp)
  70.     endm
  71.  
  72. gets    macro
  73.     movem.l    (sp)+,\1
  74.     endm
  75.  
  76. acode    macro
  77.     CNOP 0,4
  78.     endm
  79.  
  80.  
  81.     dc.b    "Symphonie DSP Plugin"    ;MAGIC String    (PRIVATE)
  82.     dc.w    1,0            ;Version,Release (PRIVATE,DO NOT CHANGE)
  83.  
  84.     ;- DSPLIB -------------------------------------------------
  85.  
  86.     jmp    InitDSP(PC)        ;Allocate Mem, Build your Tables
  87.     jmp    CleanUpDSP(PC)        ;Free Mem
  88.  
  89.     jmp    ProcDsp(PC)        ;Process DSP algorithm (interrupt)
  90.  
  91.     jmp    GetDspTitle(PC)        ;Get DSP algorithm Title
  92.     jmp    ModifyValue(PC)        ;notify changed Value
  93.  
  94.     jmp    GraphSizeModify(PC)    ;notify graph size has changed
  95.     jmp    RefreshGraph(PC)    ;notify its time for a GFX update
  96.  
  97.     jmp    StartDSP(PC)        ;notify start
  98.     jmp    StopDSP(PC)        ;notify stop
  99.     dc.l    -1
  100.  
  101.     ;- CODE --------------------------------------------------
  102.  
  103.  
  104. GoSST    move.l    a6,-(sp)
  105.     move.l    SUPERSTBASE(PC),a6
  106.     move.l    (a6,d7.w),a6
  107.     jsr    (a6)
  108.     move.l    (sp)+,a6
  109.     rts
  110.  
  111.  
  112. StartDSP
  113.     bsr    FreeDelayMem
  114.  
  115.     lea.l    RingBufMem_STATUS(PC),a0
  116.     clr.b    (a0)
  117.  
  118.     lea.l    Delay_MEM(PC),a0
  119.  
  120.     CALLSST SYS_GetMem
  121.     tst.l    d0
  122.     beq.s    .exit            ;No Memory
  123.     CALLSST GFX_AssistHexLong
  124.  
  125.     lea.l    Delay_MEM(PC),a2
  126.  
  127.     move.l    (a2),a0
  128.  
  129.     move.l    a0,DELAYREAD_PTR(a2)
  130.     lea.l    (DELAYLEN.l,a0),a1
  131.     move.l    a1,DELAYWRITE_PTR(a2)
  132.     lea.l    (DELAYBUFLEN-4,a0),a1
  133.     move.l    a1,DELAYEND_PTR(a2)
  134.  
  135.     bsr    ViewBuf
  136.  
  137.     lea.l    RingBufMem_STATUS(PC),a0
  138.     move.b    #-1,(a0)
  139.  
  140. .exit    rts
  141.  
  142. ViewBuf
  143.     BGN
  144.     lea.l    Delay_MEM(PC),a2
  145.  
  146.     move.l    DELAYREAD_PTR(a2),d0
  147.     CALLSST    GFX_AssistHexLong
  148.  
  149.     move.l    DELAYWRITE_PTR(a2),d0
  150.     CALLSST    GFX_AssistHexLong
  151.  
  152. ;    move.l    DELAYEND_PTR(a2),d0
  153. ;    CALLSST GFX_AssistHexLong
  154.  
  155. ;    move.l    DELAYSTART_PTR(a2),d0
  156. ;    CALLSST GFX_AssistHexLong
  157.  
  158. ;    CALLSST AUDIO_GetChunkLen
  159. ;    CALLSST GFX_AssistHexLong
  160.  
  161.     RET
  162.  
  163. StopDSP
  164.     lea.l    RingBufMem_STATUS(PC),a0
  165.     clr.b    (a0)
  166.  
  167.     bsr    ViewBuf
  168.     bsr    FreeDelayMem
  169.  
  170.     rts
  171.  
  172.     acode
  173. FreeDelayMem
  174.     BGN
  175.     tst.l    Delay_MEM(PC)
  176.     beq.s    .exit
  177.         lea.l    Delay_MEM(PC),a0
  178.         CALLSST SYS_FreeMem
  179.         lea.l    FreeMem_TXT(PC),a0
  180.         CALLSST GFX_AssistText
  181. .exit    RET
  182.     
  183.  
  184.         dc.l    0,0,0,0
  185.  
  186. Delay_MEM    dc.l    0,DELAYBUFLEN,ANYMEM
  187. FreeMem_TXT    dc.b    "Delay Mem has been freed.",0
  188.  
  189.  
  190.     acode
  191.  
  192. GraphSizeModify
  193.     rts
  194.  
  195. RefreshGraph
  196.     bsr    ViewBuf
  197.     rts
  198.  
  199. ModifyValue    ;INPUT (D0L,D1L)(VALUE, PARAMETER ID)
  200.     lea.l    Volume(PC),a0
  201.     move.l    d0,(a0)
  202.     rts
  203.  
  204. Volume    dc.l    256
  205.  
  206.  
  207. InitDSP        ;I(A0L)(SUPERSUPPORTTABLE_PTR)
  208.         ;O(A0L)(DSPGUI_PTR)
  209.  
  210.     lea.l    SUPERSTBASE(PC),a1
  211.     move.l    a0,(a1)
  212.  
  213.     lea.l    Welcome_TXT(PC),a0
  214.     CALLSST GFX_AssistText
  215.  
  216.     lea.l    Parameter_DEF(PC),a0
  217.     rts
  218.  
  219. CleanUpDSP    
  220.     lea.l    RingBufMem_STATUS(PC),a0
  221.     clr.b    (a0)
  222.     rts
  223.  
  224. GetDspTitle    ;OUTPUT (A0L)(DSPTitle_TXT)
  225.     lea.l    DSPTitle(PC),a0
  226.     rts
  227.  
  228.  
  229.  
  230. DELAYWRITE_PTR    EQU    -4
  231. DELAYREAD_PTR    EQU    -8
  232. DELAYEND_PTR    EQU    -12
  233. DELAYSTART_PTR    EQU    0
  234.  
  235. DELAYLEN    EQU    $6000
  236. DELAYBUFLEN    EQU    $8000
  237.  
  238.  
  239. RingBufMem_STATUS    dc.b    0    ;0= not allocated
  240.  
  241.     acode
  242.  
  243. ProcDsp        ;INPUT (D0W,A1L)(SAMPLE_NUMB,SAMPLECHUNK_PTR)
  244.     movem.l    d0-a6,-(sp)
  245.     
  246.     lea.l    RingBufMem_STATUS(PC),a0
  247.     tst.b    (a0)
  248.     beq.s    .exit
  249.  
  250.  
  251.     lea.l    Delay_MEM(PC),a0
  252.     tst.l    (a0)
  253.     beq.s    .exit
  254.  
  255.  
  256.     move.l    DELAYEND_PTR(a0),d7    ;end
  257.  
  258.     move.l    DELAYWRITE_PTR(a0),a2
  259.     lea.l    (a2,d0.w*4),a6
  260.     cmp.l    a6,d7
  261.     bhs.s    .rok
  262.  
  263.     move.l    DELAYSTART_PTR(a0),a2
  264. .rok
  265.     move.l    DELAYREAD_PTR(a0),a3
  266.     lea.l    (a3,d0.w*4),a6
  267.     cmp.l    a6,d7
  268.     bhs.s    .lok
  269.  
  270.     move.l    DELAYSTART_PTR(a0),a3
  271. .lok
  272.  
  273.  
  274.  
  275.  
  276.     subq.w    #1,d0
  277.  
  278.     move.l    Volume(PC),d3
  279.     
  280. .loop
  281.     move.l    (a1),d1
  282.  
  283.     move.l    d1,(a2)+
  284.  
  285.     move.l    (a3)+,d2
  286.  
  287.     move.w    d2,d4
  288.  
  289.     muls    d3,d4
  290.     asr.l    #8,d4
  291.     add.w    d4,d1
  292.  
  293.     swap    d1
  294.     swap    d2
  295.  
  296.     muls    d3,d2
  297.     asr.l    #8,d2
  298.     add.w    d2,d1
  299.     swap    d1
  300.     
  301.  
  302.     move.l    d1,(a1)+
  303.  
  304.     dbf    d0,.loop
  305.  
  306.  
  307. .quit
  308.     move.l    a3,DELAYREAD_PTR(a0)
  309.     move.l    a2,DELAYWRITE_PTR(a0)
  310. .exit    movem.l    (sp)+,d0-a6
  311.     rts
  312.  
  313.  
  314.  
  315.     ;- GUI ------------------------------------------------------
  316.  
  317. Parameter_DEF
  318.     dc.b    "Volume",0
  319.     dc.b    0,0,1,0        ;init
  320.     dc.b    0,0,0,0        ;min
  321.     dc.b    0,0,1,0        ;max
  322.  
  323.     dc.b    0        ;END OF GUI DEF
  324.  
  325.     ;- TITLE ----------------------------------------------------
  326.  
  327.  
  328.         dc.b    "$VER: "
  329. DSPTitle    dc.b    "Test Delay Dsp Plugin v1.0",0
  330. Welcome_TXT    dc.b    "Test Dsp: Delay",0
  331.  
  332.         even
  333. SUPERSTBASE    dc.l    0
  334. test        dc.l    0
  335.     END
  336.